package sel.me.spring.boot159.web.extension.event;

import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author shenenlu 2021年03月05日 下午17:20:00
 */
@Component
public class MyAnnotationListener {

    @EventListener
    public void listener1(EmailEvent event) {
        System.out.println("注解监听器1:" + event.getSource());
    }

    @EventListener
    @Async
    public void listener2(EmailEvent event) {
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("注解监听器2:" + event.getSource());
    }

}
